package com.zrspring.libv2.base;

import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import butterknife.ButterKnife;

/**
 * @Encoding:UTF-8
 * @ClassName: com.zrspring.lib.base
 * @Description:
 * @Version
 * @Author rui
 * @CreatDate 2016年03月19日10:42 42
 */
public abstract class BaseDialogFragment extends DialogFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return getDialogContentView(inflater);
    }

    /**
     * @MethodthName: getDialogView
     * @Description: 获取对话框内容布局
     * @params: [] \n
     * @Return:android.view.View
     * @Throw:
     */
    private View getDialogContentView(LayoutInflater inflater) {
        View view = inflater.inflate(iniLayout(), null);
        ButterKnife.bind(this, view);
        iniView(view);
        //让整个布局显示在输入法上面
        getDialog().getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        return view;
    }

    public abstract int iniLayout();

    public abstract void iniView(View contentView);

    public abstract void cleanData();

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        cleanData();
        ButterKnife.unbind(this);
    }
}
